package com.redxiii.safesync;

import java.io.File;
import java.io.Serializable;


public class Archive implements Comparable<Archive>, Serializable{

	private static final long serialVersionUID = 1L;
	private volatile File	file;
	
	protected String 	name;
	protected String 	absoluteName;
	protected String	innerPath;
	protected long		size;
	protected long		modifiedDate;
	protected long		creationDate;
	protected byte[]	hash;

	public Archive(File file, File rootPath) {
		this.file = file;
		this.absoluteName = this.file.getAbsolutePath().substring(rootPath.getAbsolutePath().length());
		this.innerPath = file.getParent().substring(rootPath.getAbsolutePath().length());
		this.name = file.getName();
		this.size = file.length();
		this.modifiedDate = file.lastModified();
	}
	
	public void setSize(long size) {
		this.size = size;
	}
	public void setModifiedDate(long modifiedDate) {
		this.modifiedDate = modifiedDate;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public int compareTo(Archive other) {
		return this.absoluteName.compareTo(other.absoluteName);
	}
	
	public boolean isNewerThen(Archive object) {
		return this.modifiedDate > object.modifiedDate;
	}
	
	public void setHash(byte[] hash) {
		this.hash = hash;
	}

	public String getName() {
		return name;
	}

	public String getAbsoluteName() {
		return absoluteName;
	}
	public void setAbsoluteName(String innerPath) {
		this.absoluteName = innerPath;
	}
	
	public String getInnerPath() {
		return innerPath;
	}
	public void setInnerPath(String innerPath) {
		this.innerPath = innerPath;
	}

	public long getSize() {
		return size;
	}

	public long getModifiedDate() {
		return modifiedDate;
	}

	public byte[] getHash() {
		return hash;
	}

	public File getFile() {
		return file;
	}
	
	
	
	
}
